export default {
  state: {
    isCollapse: false,
    //菜单数据
    menu: [],
    tags: [
      {
        path: '/home',
        name: 'home',
        fullPath: '/home',
        label: '公司简介',
        meta: { title: '公司简介', key: 'home', keepAlive: true },
        url: '/home',
      },
    ],
  },
  mutations: {
    collapesMenu(state) {
      state.isCollapse = !state.isCollapse;
    },
    //设置menu的数据
    getMenu(state, vai) {
      state.menu = vai;
      localStorage.setItem('menu', JSON.stringify(vai));
    },
    // 更新面包屑
    selectMenu(state, item) {
      //判断添加的数据是否为首页
      console.log(item);
      if (item.name !== 'home' && item.url !== '/home2') {
        // const index = state.tadsLst.findIndex(item => item.name === item.name)
        const find = state.tags.find((item2) => item2.url === item.url);
        // 如果不在
        if (!find) {
          state.tags.push({ ...item, label: item.name, path: item.url });
        }
      }
    },
    // 删除指定的tag
    closeTag(state, item) {
      const index = state.tags.findIndex((val) => val.name == item.name);
      state.tags.splice(index, 1);
    },
  },
};
